package leetcode

func findErrorNums(nums []int) []int {
    ln := len(nums)
    noRepeat := make([]int, ln + 1)
    repeatNum := 0
    errorSum := 0

    for _, num := range nums {
        if noRepeat[num] == 0 {
            noRepeat[num] ++
        } else {
            repeatNum = num
        }

        errorSum += num
    }

    return []int{repeatNum, ln * (ln + 1) / 2 - errorSum + repeatNum}
}

